﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DSTMEETING.BLL.Services
{
    public class DeleteService
    {
        public bool DeleteMeeting(Guid id)
        {
            using(DSTDbContext dbContext = new DSTDbContext())
            {
                Entity.Meeting meeting = new Entity.Meeting();
                meeting.Id = id;

                dbContext.Entry<Entity.Meeting>(meeting).State = System.Data.Entity.EntityState.Deleted;

                try
                {
                    dbContext.SaveChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    //log
                    return false;
                }


                /*
                Entity.Meeting meeting = dbContext.Set<Entity.Meeting>().SingleOrDefault(p => p.Id == id);
                if (meeting != null)
                {
                    dbContext.Set<Entity.Meeting>().Remove(meeting);

                    try
                    {
                        dbContext.SaveChanges();
                        return true;
                    }
                    catch(Exception ex)
                    {
                        //log
                        return false;
                    }
                }

                return true;*/
            }
        }
    }
}
